package com.ctbu.tourism.controller.restful;

import com.ctbu.tourism.entity.Result;
import com.ctbu.tourism.service.CollectionService;
import com.ctbu.tourism.utils.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class CollectionController {
    @Autowired
    CollectionService collectionService;

    @GetMapping("/user/collection/users")
    Result getUserCollectionUserByUID(@RequestParam("uid") Integer uid){
        return ResultUtil.success(collectionService.getUserCollectionUserByUID(uid));
    }

    @GetMapping("/user/collection/forums")
    Result getUserCollectionForumByUID(@RequestParam("uid") Integer uid){
        return ResultUtil.success(collectionService.getUserCollectionForumByUID(uid));
    }

    @GetMapping("/user/collection/posts")
    Result getUserCollectionPostByUID(@RequestParam("uid") Integer uid){
        System.out.println(uid);
        return ResultUtil.success(collectionService.getUserCollectionPostByUID(uid));
    }

    @GetMapping("/user/collections/cnums/{uid}")
    Result getUserCollectionNumsByUID(@PathVariable("uid") Integer uid){
        return ResultUtil.success(collectionService.getUserCollectionNumsByUID(uid));
    }

    @DeleteMapping("/user/collections/cancal")
    Result deleteUserCollectionByUIDAndOID(@RequestParam("id") Integer id){
        return ResultUtil.success(collectionService.deleteUserCollectionByUIDAndOID(id));
    }

    @GetMapping("/user/followers")
    Result getUserFollowersByUID(@RequestParam("oid") Integer oid){
        return ResultUtil.success(collectionService.getUserFollowersByUID(oid));
    }

    @GetMapping("/collection/opid/{opid}")
    Result getCollectionPostUids(@PathVariable("opid") Integer opid){
        return ResultUtil.success(collectionService.getCollectionPostUids(opid));
    }

    @GetMapping("/collection/oid/user/{ouid}")
    Result getCollectionUserUids(@PathVariable("ouid") Integer ouid){
        return ResultUtil.success(collectionService.getCollectionUserUids(ouid));
    }

    @GetMapping("/collection/oid/ofid/{ofid}")
    Result getCollectionForumUids(@PathVariable("ofid") Integer ofid){
        return ResultUtil.success(collectionService.getCollectionForumUids(ofid));
    }

    @PutMapping("/collection/add/u")
    Result addCollectionU(@RequestParam("uid") Integer uid,@RequestParam("ouid") Integer ouid){
        return ResultUtil.success(collectionService.addCollectionU(uid,ouid));
    }

    @PutMapping("/collection/add/f")
    Result addCollectionF(@RequestParam("uid") Integer uid,@RequestParam("ofid") Integer ofid){
        return ResultUtil.success(collectionService.addCollectionF(uid,ofid));
    }

    @PutMapping("/collection/add/p")
    Result addCollectionP(@RequestParam("uid") Integer uid,@RequestParam("opid") Integer opid){
        return ResultUtil.success(collectionService.addCollectionP(uid,opid));
    }

    @DeleteMapping("/collection/delete/u")
    Result deleteCollectionU(@RequestParam("uid") Integer uid,@RequestParam("ouid") Integer ouid){
        return ResultUtil.success(collectionService.deleteCollectionU(uid,ouid));
    }

    @DeleteMapping("/collection/delete/f")
    Result deleteCollectionF(@RequestParam("uid") Integer uid,@RequestParam("ofid") Integer ofid){
        return ResultUtil.success(collectionService.deleteCollectionF(uid,ofid));
    }

    @DeleteMapping("/collection/delete/p")
    Result deleteCollectionP(@RequestParam("uid") Integer uid,@RequestParam("opid") Integer opid){
        return ResultUtil.success(collectionService.deleteCollectionP(uid,opid));
    }

    @GetMapping("/message/collection")
    Result getMessageCollection(@RequestParam("uid") Integer uid){
        return ResultUtil.success(collectionService.getMessageByUID(uid));
    }
    @PutMapping("/message/collection/update/status")
    Result updateCollectionStatus(@RequestParam("id") Integer id){
        return ResultUtil.success(collectionService.updateCollectionStatus(id));
    }
}
